<template>
  <div class="main">
    <div class="form_content">
      <NScrollbar>
        <NSpin :show="spinShow">
          <div class="content">
            <div class="topTitle">公告详情</div>
            <div class="basin-left">
              <div class="box">
                <span>公告标题：</span>
                <span>{{ formValue.noticeTitle }}</span>
              </div>
              <div class="box">
                <span>公告时间：</span>
                <span>{{ formValue.startDate + '~' + formValue.endDate }}</span>
              </div>
              <div class="box">
                <span>征集说明：</span>
                <span v-html="formValue.description"></span>
                </div>
              <!-- <div class="box">
                <span>征集提示：</span>
                <span style="white-space: pre-wrap;">{{ formValue.prompt }}</span>
              </div> -->
            </div>
          </div>
        </NSpin>
      </NScrollbar>
    </div>
  </div>
  <FixedAction>
    <NSpace>
      <NButton
        style="width: 78px; color: #5fb17f"
        ghost
        @click="goBack"
      >
        <template #icon>
          <NImage
            :src="VBackImg"
            style="width: 50rem; height: 50rem"
            preview-disabled
          ></NImage>
        </template>
        返回
      </NButton>
    </NSpace>
  </FixedAction>
</template>
<script setup lang="ts">
import { NScrollbar, NSpace, NButton, NSpin, NImage } from 'naive-ui'
import { useRoute } from 'vue-router'
import router from '@/router'
import { ref, watch, reactive } from 'vue'
import FixedAction from '@/components/FixedAction.vue'
import { keysOf } from '@/utils/object'
import { sendRequest } from '@/utils/api'
import { useTagStore } from '@/stores/layout'
import type { HttpResponse } from '@/utils/http'
import VBackImg from '@/assets/images/back.png'

const props = defineProps({
  id: String
})

const route = useRoute()
const tags = useTagStore().tags
const formValue = reactive({
  noticeTitle: '',
  description: '',
  prompt: '',
  startDate: '',
  endDate: ''
})
// 返回
const goBack = () => {
  const index = tags.findIndex((item: any) => item.path === router.currentRoute.value.fullPath)
  
    tags.splice(index, 1)
if (tags.length == 0) {
    router.push({ path: '/OA/Workbench/UserDesktop' })
  } else history.back()
}
// 获取详情
const spinShow: any = ref(false)
const idT = ref()
const getInfo = async () => {
  idT.value = router.currentRoute.value.params.id
  console.log(idT.value)
  spinShow.value = true
  await sendRequest<HttpResponse>({
    module: 'collectNotice',
    api: 'info',
    uri: {
      id: idT.value
    }
  }).then(([err, res]) => {
    if (err) return
    keysOf(res.data).forEach((e) => {
      {
        // @ts-ignore
        formValue[e] = res.data[e] as never
      }
    })
  })
  spinShow.value = false
}

watch(
  () => route,
  () => {
    if (route.name == 'CollectionAnnouncementManagementDetailList') getInfo()
  },
  { deep: true, immediate: true }
)
</script>
<style scoped lang="scss">
@mixin CommonFont {
  font-size: 18rem;
  font-family: PingFangSC, PingFang SC;
  font-weight: 400;
  color: #333333;
}

.main {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow: hidden;

  .form_content {
    width: 100%;
    height: 100%;
    padding: 20rem 20rem 0;

    .topTitle {
      font-size: 22px;
      font-family: PingFangSC, PingFang SC;
      font-weight: 500;
      color: #5fb17f;
      margin-bottom: 10rem;
    }

    .content {
      display: flex;
      flex-direction: column;
      width: 100%;
      height: 100%;
      padding: 18rem 33rem 120rem;
      overflow-y: scroll;
      background-color: #ebeceb;
      @include CommonFont;
      .basin-left {
        .box {
          margin: 20px 0;
          font-family: auto;
          .boxLeft{
            display: inline-block;
            width: 100px;
          }
        }
      }
    }
  }
}

.content::-webkit-scrollbar {
  display: none;
}

:deep(.n-spin-container) {
  width: 100%;
  height: 100%;
}

:deep(.n-scrollbar-container) {
  width: 100%;
  height: 100%;
}

:deep(.n-scrollbar-content) {
  width: 100%;
  height: 100%;
}

:deep(.n-spin-content) {
  width: 100%;
  height: 100%;
}
:deep(.w-e-text-container *, .w-e-toolbar *){
font-family: auto;
}
</style>
